package com.cib.process.chat.core.handler.impl;

import com.cib.process.bean.CheckType;
import com.cib.process.bean.ServiceResult;
import com.cib.process.chat.bean.CommonResult;
import com.cib.process.chat.bean.PlayType;
import com.cib.process.chat.bean.QueryResult;
import com.cib.process.chat.core.handler.ActionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;

/**
 * @描述:
 * @Author: zhangh
 * @Time: 2021/2/20 9:51
 **/
public class ExecptionActionHandler implements ActionHandler {
    @Autowired
    RedisTemplate redisTemplate;
    @Override
    public ServiceResult execute(QueryResult queryResult) {
        CommonResult result=new CommonResult();
        result.setType(PlayType.TTS);
        result.setContext(queryResult.getSuggestAnswer());
        result.setCanbreak(CheckType.N.name());
        //任意设置execption
        redisTemplate.opsForValue().set("execption"+queryResult.getSessionId(),"exist",3*60, TimeUnit.SECONDS);

        return ServiceResult.buildSuccessResult(result,queryResult.getSessionId(),queryResult.getAction());
    }
}
